home *** CD-ROM | disk | FTP | other *** search
- "-----------------------------------------------------------------"
- " Object Class is the Root of all other Classes in AmigaTalk. "
- " The perform: methods are NOT part of the original Little "
- " Smalltalk code. They might be moved sometime in the future. "
- "-----------------------------------------------------------------"
-
- Class Object
- [
- identityHash " Added on 02-Apr-2002 "
- ^ <primitive 5 self>
- |
- == anObject
- ^ <primitive 7 self anObject >
- |
- ~~ x
- ^ (self == x) not
- |
- = x
- ^ (self == x) "Is the receiver equal to x??"
- |
- ~= x
- ^ (self = x) not "Is the receiver NOT equal to x??"
- |
- asString
- ^ <primitive 152 (self class)> "Avoid recursion!"
- "^ self class printString" "<<--Infinite recursive method."
- |
- asSymbol
- ^ self asString asSymbol "Return the class a Symbol."
- |
- yourself "Synonym for self."
- ^ self
- |
- class
- ^ <primitive 1 self>
- |
- copy
- ^ self shallowCopy
- |
- deepCopy ! size newobj !
- size <- <primitive 4 self>.
-
- (size < 0)
- ifTrue: [^ self] "if special just copy object"
- ifFalse: [ newobj <- self class new.
-
- (1 to: size) do: [:i |
- <primitive 112 newobj i ( <primitive 111 self i > copy ) > ].
- ^ newobj
- ]
- |
- first
- ^ self
- |
- do: aBlock ! item !
- item <- self first.
-
- ^ [item notNil]
- whileTrue: [ aBlock value: item.
- item <- self next
- ]
- |
- do: aBlock without: anObject ! item ! "Added on 20-Jun-2001 (JTS)"
- (anObject == nil)
- ifFalse: [ item <- self first.
-
- ^ [item notNil]
- whileTrue: [ (item ~~ anObject)
- ifTrue: [aBlock value: item].
-
- item <- self next
- ]
- ]
-
- ifTrue: [ self do: aBlock ]
- |
- error: aString
- <primitive 122 aString self>
- |
- isKindOf: aClass ! objectClass !
- objectClass <- self class.
-
- [objectClass notNil] whileTrue:
- [(objectClass == aClass) ifTrue: [^ true].
-
- objectClass <- objectClass superClass].
- ^ false
- |
- isMemberOf: aClass
- ^ aClass == self class
- |
- ifKindOf: aClass thenDo: aBlock
- ^ (self isKindOf: aClass)
- ifTrue: [aBlock value: self]
- |
- isNil
- ^ false
- |
- next
- ^ nil
- |
- notNil
- ^ true
- |
- print
- <primitive 121 (self printString)>
- |
- printNoReturn
- <primitive 120 (self printString)>
- |
- printString
- ^ self asString
- |
- respondsTo: cmd
- ^ self class respondsTo: cmd
- |
- shallowCopy ! size newobj !
- size <- <primitive 4 self>.
-
- (size < 0)
- ifTrue: [^ self] "if special just copy object"
- ifFalse: [ newobj <- self class new.
-
- (1 to: size) do: [:i |
- <primitive 112 newobj i <primitive 111 self i > > ].
-
- ^ newobj ]
- |
- asciiToString: aNumber ! masked !
- " Convert aNumber into a single-character String: "
-
- masked <- <primitive 23 aNumber 16rFF>.
-
- ^ <primitive 96 masked>
- |
- subclassResponsibility: methodString ! msg !
- msg <- String new: 'Method ',methodString,' should be implemented in a SubClass!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- notImplemented: methodString ! msg !
- msg <- String new: 'Method ',methodString,' NOT implemented!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- doesNotUnderstand: methodString ! msg !
- msg <- String new: 'Method ',methodString,' NOT understood!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- shouldNotImplement: methodString ! msg !
- msg <- String new: 'Method ',methodString,' should NOT BE implemented!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- notYetImplemented
- ^ <primitive 181 13 'NOT yet implemented!' 'User ERROR:' 'OKAY'>
- |
- perform: selector ! argArray !
-
- " Send the unary selector to the receiver: "
-
- (selector isMemberOf: Symbol)
- ifFalse: [^ self error: 'Selector argument must be a Symbol!'].
-
- (self respondsTo: selector)
- ifFalse: [^ self error: 'Do NOT respondTo: ', selector ].
-
- argArray <- Array new: 1.
-
- argArray at: 1 put: self.
-
- ^ <primitive 143 argArray selector>
- |
- perform: selector orSendTo: otherTarget
-
- " If I wish to intercept and handle selector myself,
- * do it; else send it to otherTarget
- "
- ^ otherTarget perform: selector
- |
- perform: selector with: anObject ! argArray !
-
- " Send the selector, aSymbol, to the receiver with
- * anObject as its argument:
- "
- (selector isMemberOf: Symbol)
- ifFalse: [^ self error: 'Selector argument must be a Symbol!'].
-
- (self respondsTo: selector)
- ifFalse: [^ self error: 'Do NOT respondTo: ', selector ].
-
- argArray <- Array new: 2.
-
- argArray at: 1 put: self.
- argArray at: 2 put: anObject.
-
- ^ <primitive 143 argArray selector>
- |
- perform: selector withArguments: argArray ! lsArray !
-
- " Send the selector, aSymbol, to the receiver with
- * arguments in argArray. Fail if the number of
- * arguments expected by the selector does not match
- * the size of lsArray:
- "
- (argArray size = 0)
- ifTrue: [ ^ self perform: selector ]. " Short-circuit stupid User "
-
- (argArray size = 1) " Short-circuit stupid User: "
- ifTrue: [ ^ self perform: selector with: (argArray at: 1) ].
-
- " Go the long way around: "
-
- lsArray <- Array new: ((argArray size) + 1).
-
- (selector isMemberOf: Symbol)
- ifFalse: [^ self error: 'Selector argument must be a Symbol!'].
-
- (selector numArgs = argArray size)
- ifFalse: [^ self error: 'Incorrect number of arguments!'].
-
- (self respondsTo: selector)
- ifFalse: [^ self error: 'Do NOT respondTo: ', selector ].
-
- lsArray at: 1 put: self.
-
- (2 to: lsArray size)
- do: [:ele | lsArray at: ele put: (argArray at: (ele - 1))].
-
- ^ <primitive 143 lsArray selector>
- |
- perform: selector with: firstObject with: secondObject ! argArray !
-
- " Send the selector, aSymbol, to the receiver with the
- * given arguments.
- "
- (selector isMemberOf: Symbol)
- ifFalse: [^ self error: 'Selector argument must be a Symbol!'].
-
- (self respondsTo: selector)
- ifFalse: [^ self error: 'Do NOT respondTo: ', selector ].
-
- argArray <- Array new: 3.
-
- argArray at: 1 put: self.
- argArray at: 2 put: firstObject.
- argArray at: 3 put: secondObject.
-
- ^ <primitive 143 argArray selector>
- |
- perform: selector with: firstObject with: secondObject with: thirdObject ! argArray !
-
- " Send the selector, aSymbol, to the receiver with the given arguments: "
-
- (selector isMemberOf: Symbol)
- ifFalse: [^ self error: 'Selector argument must be a Symbol!'].
-
- (self respondsTo: selector)
- ifFalse: [^ self error: 'Do NOT respondTo: ', selector ].
-
- argArray <- Array new: 4.
-
- argArray at: 1 put: self.
- argArray at: 2 put: firstObject.
- argArray at: 3 put: secondObject.
- argArray at: 4 put: thirdObject.
-
- ^ <primitive 143 argArray selector>
- |
- performUpdate: aSymbol with: anObject
- self perform: aSymbol with: anObject
- |
- performUpdate: aSymbol
- self perform: aSymbol
- |
- breakPoint: msgString
- ^ <primitive 209 10 0 msgString>
- ]
-